<?php
$this->widget('webroot.admin.protected.extensions.fancybox.EFancyBox', array('target' => '.fan', 'config' => array('width' => 690, 'height' => 500,'type'=>'iframe','hideOnOverlayClick'=>false)));
?>
<?php $this->beginWidget('application.widget.site.bannerWidget'); ?>
<?php $this->endWidget(); ?>
<div id="contener" _height="auto">
	<div class="left_menu">
	<?php $this->beginWidget('application.widget.site.leftWidget'); ?>
	<?php $this->endWidget(); ?>
	<?php $this->beginWidget('application.widget.site.faceWidget'); ?>
	<?php $this->endWidget(); ?>
	</div>
	<div class="main">
		<?php $this->beginWidget('application.widget.site.newWidget'); ?>
		<?php $this->endWidget(); ?>
		<div class="right_mainBox">
			<div class="right_mainBox_top"></div>
			<div class="mainMenu"><img src="images/mainbutton4.png" alt="人氣限定" width="726" height="40" border="0" usemap="#Map" />
				<map name="Map" id="Map">
					<area shape="rect" coords="22,3,156,36" href="<?=Yii::app()->createUrl('activity/index',array('class'=>'人氣限定'))?>" target="_self" alt="人氣限定" title="人氣限定" />
					<area shape="rect" coords="158,3,292,36" href="<?=Yii::app()->createUrl('activity/index',array('class'=>'時間限定'))?>" target="_self" alt="時間限定" title="時間限定" />
					<area shape="rect" coords="294,4,426,35" href="<?=Yii::app()->createUrl('activity/index',array('class'=>'贊助限定'))?>" target="_self" alt="贊助限定" title="贊助限定" />
					<area shape="rect" coords="430,1,564,37" href="<?=Yii::app()->createUrl('activity/closed')?>" target="_self" alt="已結束" title="已結束" />
				</map>
			</div>
			<div class="mainContentBox">
				<?php
			if($rowTable){
				foreach($rowTable as $row){
			?>
				<div class="memberBOX1">
					<table width="720" border="0" align="center" cellpadding="0" cellspacing="3">
						<tr>
							<td height="30" colspan="3" align="center" valign="middle" background="images/bg2.gif">活動訊息</td>
							<td width="148" align="center" valign="middle" background="images/bg2.gif">開獎資訊/中獎人</td>
							<td width="80" align="center" valign="middle" background="images/bg2.gif">狀態</td>
						</tr>
						<tr>
							<td height="195" width="160" align="center" valign="middle">
								<div class="memberBOX1_img"><a href="<?=Yii::app()->createUrl('activity/detail',array('id'=>$row->activityid))?>"><img src="<?=Yii::app()->params['prizePath']?>/<?=$row->prize->pic?>" width="320" height="240" /></a></div>
							</td>
							<td colspan="2" width="155" align="left" valign="top">
								<ul>
									<li class="space666">活動ID：
										<a href="<?=Yii::app()->createUrl('activity/detail',array('id'=>$row->activityid))?>"><?=$row->serial?></a>
									</li>
									<li class="space666">活動類別：<span class="green"><a href="<?=Yii::app()->createUrl('activity/index',array('class'=>$row->class))?>" title="<?=$row->class?>" target="_self">
										<?=$row->class?>
										</a></span></li>
									<li class="space666">商品資訊：<br />
										<span class="Orange">
										<?=$row->prize->prizename?>
										</span><br />
										<?=Helper::truncate_utf8_string($row->prize->description,50)?>
									</li>									
								</ul>
							</td>
							<td align="center" valign="middle" bgcolor="#E1E1E1">
							<?php
							$codeArr = array();
							$userArr = array();
							if($row->records){
								foreach($row->records as $record){
									$codeArr[] = $record->code;
									$userArr[] = $record->user->username;
								}
							}
							?>
								<?php
								if($row->status==4){
								?>
								<p class="blue"><a class="fan" href="<?=Yii::app()->createUrl('activity/record',array('id'=>$row->activityid,'win'=>1))?>" title="中獎號碼明細">中獎號碼明細</a></p>
								<?php
								}
								?>
								<p class="blue"><a class="fan" href="<?=Yii::app()->createUrl('activity/record',array('id'=>$row->activityid))?>" title="抽獎號碼明細">抽獎號碼明細</a></p>
							</td>
							<td align="center" valign="middle" bgcolor="#E1E1E1">已結束</td>
						</tr>
					</table>
				</div>
				<?php
				}
			}
			?>
				<div id="pager" align="center" style="margin:10px 0;">
				<?php  
				$this->widget('CLinkPager',array(  
					'header'=>'',  
					'firstPageLabel' => '<<',
					'lastPageLabel' => '>>',
					'prevPageLabel' => '<',
					'nextPageLabel' => '>',
					'pages' => $pages,  
					'maxButtonCount'=>13  
					));  
				?>
				</div>
			</div>
			<div class="right_mainBox_bottom"></div>
		</div>
	</div>
</div>
<script>
$(document).ready(function() {
<?php
if($timeArr){
?>
RF = new Object();
<?php
	foreach($timeArr as $tKey=>$tValue){
?>
RF['<?=$tKey?>'] = '<?=$tValue?>';
<?php
	}
?>
for ($f in RF) {
	if ($f == null) { 
		continue;
	}
	onTimer($f,RF[$f],changeShowTime,onTimeEnd);
}
<?php
}
?>
});
 
// 该函数用于显示倒计时
function changeShowTime(id,time) {
    /* 该函数内编写显示倒计时的语句 */  
    $(id).html(time);    
}
//倒計時結束的時候執行的函數
function onTimeEnd(id){
	$.post('<?php echo CHtml::normalizeUrl(array('/activity/opration'));?>',{'serial':id}, function (data) {
		var ret = $.parseJSON(data);
		location.reload(true);
	});	
}
</script>